<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            list-style: none;
        }
        #box{
            width: 200px;
            margin: 0 auto;
            text-align: center;
        }
        #box #btn{
            margin-top: 20px;
        }
        #box #list{
            border: 1px solid black;
            width: 40px;
            margin: 5px auto;
        }
        #list #close{
            border: 1px solid black;
        }
        #btn #list{
            cursor: pointer;
        }
        #list{
            display: none;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="button" id="btn" value="输入法">
        <ul id="list">
            <li>搜狗</li>
            <li>微软</li>
            <li id="close">关闭</li>
        </ul>
    </div>
</body>
<script>
    window.onload = function(){
        var oBtn = document.getElementById('btn')
        var oList = document.getElementById('list')
        var oLi = document.getElementsByTagName('li')
        var oClose = document.getElementById('close')
        oClose.onclick = function(){
            oList.style.display="none"
        }
        oBtn.onclick = function(){
            if(oList.style.display != "block"){
                oList.style.display = "block"
            }else{
                oList.onclick()
            }
        }
        for(var i = 0 ; i < oLi.length; i++){
            oLi[i].onmouseover = function(){
                this.style.background = "blue"
                this.style.color = "red"
            }
            oLi[i].onmouseout = function(){
                this.style.background = ""
                this.style.color = ""
            }
        }
    }
</script>
</html>